﻿/*****************************************************************************/
/* Stored Procedure :: ApplicationStartup                                    */
/*****************************************************************************/
/* Copyright (C) 2003-2004, Perot Systems Corporation. All right reserved.   */
/* Developer: Dima Frenkel (dima.frenkel@ps.net)                             */
/* Started:  08/04/2004                                                      */
/*****************************************************************************/
CREATE PROCEDURE [Kernel].[ApplicationStartup]( 
	@ApplicationName VARCHAR(128),
	@ApplicationVersion VARCHAR(32),
	@StartupParameters VARCHAR(128),
	@Host VARCHAR(64) = null,
	@StartTime datetime = null
)
AS 
BEGIN
    DECLARE @newOID BIGINT
    
    SET @ApplicationName    = ISNULL( @ApplicationName, APP_NAME() )
    SET @ApplicationVersion = ISNULL( @ApplicationVersion, 'UNKNOWN' )
    SET @StartupParameters  = ISNULL( @StartupParameters, '' )
    SET @Host               = ISNULL( @Host, HOST_NAME() )
    SET @StartTime          = ISNULL( @StartTime, GETDATE() )
    
    INSERT INTO ApplicationLog( ApplicationName, ApplicationVersion, StartupParameters, Host, StartTime, FinishTime  )
    VALUES( @ApplicationName,
            @ApplicationVersion,
            @StartupParameters,
            @Host,
            @StartTime,
            NULL )
    
    SET @newOID = SCOPE_IDENTITY()
    
    SELECT OID, [timestamp]
    FROM ApplicationLog WHERE OID = @newOID
END


